from page.focus_project_page import FocusProjectPage
import random as r
from page.common_tools import CommonTools
import time as t


class FocusResourcePage(FocusProjectPage, CommonTools):

    def publish_recourse(self):
        self.find_button('发布').click()
        self.find_static_text(string='请输入标题', contains_flag=1).click()
        self.find_static_text(string='请输入标题', contains_flag=1).send_keys("App面授资源自动化测试%d" % r.randint(100, 999))
        self.find_static_text('请选择').click()
        self.find_static_text('按班级').click()
        # self.swipe(369, 645, 369, 645)  # 确定
        self.find_static_text(string="确定",contains_flag=1).click()
        self.find_static_text(string='请输入描述', contains_flag=1).click()
        self.find_static_text(string='请输入描述', contains_flag=1).send_keys("这是发布资源的描述，发布资源的描述。。。。。。")
        self.hide_keyboard()
        self.find_button('附件').click()
        self.find_button('xiangji').click()
        self.take_ptoto()
        self.find_button('确认').click()
        t.sleep(3)
        self.find_static_text("我分享的").click()
        self.swipe_dr("down")
        self.swipe(141,180,141,180)  #选择我分享的第一个
        self.find_button(string="more").click()
        self.find_button("收藏").click()
        self.find_button(string="返回",contains_flag=1).click()
        self.find_static_text("我收藏的").click()
        self.swipe_dr("down")
        t.sleep(1)
        self.swipe(141, 180, 141, 180)  # 选择我分享的第一个
        self.find_button(string="more").click()
        self.find_button("取消收藏").click()
        t.sleep(1)
        self.find_button(string="返回",contains_flag=1).click()
        self.find_button(string="common back dark icon",contains_flag=1).click()
        self.find_button(string="数学班",contains_flag=1).click()


if __name__ == "__main__":
    test = FocusResourcePage()
    test.enter_project()
    test.enter_tools("资源")
    test.publish_recourse()
